package com.example.weixinsystem.controller;

import com.example.weixinsystem.service.SysUserService;
import com.weixin.common.core.domain.LoginUser;
import com.weixin.common.core.domain.Result;
import com.weixin.common.core.form.LoginForm;
import com.weixin.common.security.annotations.Inner;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 用户控制器
 *
 * @version 1.0.0
 * @className: UserController
 * @description: 用户控制器
 * @author: zhangjunfa
 * @date: 2023/6/8 17:09
 */
@Slf4j
@RestController
@RequestMapping(value = "/user")
public class UserController {

    private SysUserService sysUserService;

    public UserController(SysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }

    /**
     * 根据用户名获取用户基本信息
     *
     * @param username 用户名
     * @return 用户基本信息
     */
    @Inner
    @GetMapping("/info/{username}")
    public Result<?> getUserInfo(@PathVariable("username") String username) {
        LoginUser userInfo = this.sysUserService.getUserInfo(username);
        return Result.ok(userInfo);
    }

}
